home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / TTY.ARJ / MON.CPP < prev    next >
C/C++ Source or Header  |  1992-03-11  |  870b  |  77 lines

  1. //    Written by Chris Sokol
  2.  
  3. #include <bios.h>
  4. #include <stdio.h>
  5. #include "tty.h"
  6.  
  7. static void        Init();
  8. static void        Run();
  9. static void        Term();
  10.  
  11. static TTY        *tty;
  12.  
  13. void    Init()
  14. {
  15.     TTYInit();
  16.  
  17.     tty = new TTY("COM2", 256, 256);
  18.     tty->Baud(9600);
  19.     tty->Bits(8);
  20.     tty->Prty('-');
  21.     tty->Stop(1);
  22.  
  23.     tty->Put('\r');
  24. }
  25.  
  26. int    main(int, char*[])
  27. {
  28.     printf("TTY test started.\n");
  29.  
  30.     Init();
  31.  
  32.     Run();
  33.  
  34.     Term();
  35.  
  36.     printf("\rTTY test terminated.\n");
  37.  
  38.     return 0;
  39. }
  40.  
  41. void    Run()
  42. {
  43.     while (1)
  44.         if (bioskey(1))
  45.             {
  46.             uint    k;
  47.  
  48.             k = bioskey(0);
  49.  
  50.             if (k == 0x2d00)
  51.                 break;
  52.  
  53.             k &= 0xff;
  54.  
  55.             if (!k)
  56.                 continue;
  57.  
  58.             tty->Put(k);
  59.             }
  60.         else if (tty->Avail())
  61.             {
  62.             uint    e;
  63.  
  64.             e = tty->Get();
  65.  
  66.             if (e / 0x100 == TTYrxchar)
  67.                 printf("%c", e & 0xff);
  68.             }
  69. }
  70.  
  71. void    Term()
  72. {
  73.     delete tty;
  74.  
  75.     TTYTerm();
  76. }
  77.